/**
 * 首页tab相关接口
 */
import type { AddFamilyMemberParams, GetDataBoardResult, GetFamilyGroupResult, GetFamilyMembersResult, ReadResult } from './type';
import { get, post } from '@/utils/request';

enum URL {
  getReadResult = '/app/userMainPage/getReadResult',
  getDataBoard = '/app/custCourse/dataBoard',
  getFamilyGroup = '/app/user/familyGroup',
  getFamilyMembers = '/app/user/familyMembers',
  delFamilyMember = '/app/user/delFamilyMember',
  addFamilyMember = '/app/auth/addFamilyMember',
  getShareCode = '/app/auth/getShareCode',
  getFamilyShareInfo = '/app/auth/familyShareInfo',
}

// 查询阅读成果
export const getReadResult = () => get<ReadResult>({ url: URL.getReadResult });

// 我的数据中心看板
export const getDataBoard = () => get<GetDataBoardResult>({ url: URL.getDataBoard });
// 家庭列表
export const getFamilyGroup = () => get<GetFamilyGroupResult[]>({ url: URL.getFamilyGroup });

// 家庭成员列表
export const getFamilyMembers = (familyCode: string) => post<GetFamilyMembersResult>({ url: URL.getFamilyMembers, data: { familyCode } });

// 删除家庭成员
export const delFamilyMember = (id: string) => post({ url: URL.delFamilyMember, data: { id } });

// 添加家庭成员
export const addFamilyMember = (data: AddFamilyMemberParams) => post({ url: URL.addFamilyMember, data });

// 点击邀请获取code
export const getShareCode = (data: { familyRoleName: string; familyCode: string }) => post<any>({ url: URL.getShareCode, data });

// 获取邀请信息
export const getFamilyShareInfo = (data: { code: string }) => post<any>({ url: URL.getFamilyShareInfo, data });
